/*
 * Copyright (c) 2020, China Mobile Communications Group Co.,Ltd.
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2020-11-14     cmcc       the first version
 */
#ifndef NINESKY_TEXT_RECOGNITION_NS_TEXT_RECOG_H_
#define NINESKY_TEXT_RECOGNITION_TEXT_RECOG_H_

#define URL_TEXT_LICENCE_RECOG "http://aiaas.cmri.cn:8080/ivr/v1/licence_ocr?"
#define URL_TEXT_OCR_RECOG "http://aiaas.cmri.cn:8080/ivr/v1/ocr?"

//type of IDs
#define COMMAND_ID_INVOICE "100001"
#define COMMAND_ID_ID_CARD "200001"
#define COMMAND_ID_BANK_CARD "300001"
#define COMMAND_ID_VEHICLE_PLATE "400001"

#define BUSINESS_ID_INVOICE "1001"
#define BUSINESS_ID_ID_CARD "2001"
#define BUSINESS_ID_BANK_CARD "3001"
#define BUSINESS_ID_VEHICLE_PLATE "4001"

//text recognition result
typedef struct
{
    char *invoiceCode;

    char *invoiceNumber;
    char *invoiceDate;
    char *invoiceAmount;
    char *capitalAmount;

    char *buyerName;
    char *buyerTaxNumber;
    char *sellerName;
    char *sellerTaxNumber;
} NS_Invoice;

typedef struct
{
    char *address;

    char *authority;
    char *birthday;
    char *effectiveDate;
    char *ethnicity;

    char *expiryDate;
    char *gender;
    char *idNumber;
    char *name;
} NS_Id_Card;

typedef struct
{
    char *cardNumber;
    char *expiryDate;
} NS_Bank_Card;

typedef struct
{
    char *carNumber;
} NS_Vehicle_Plate;

typedef struct
{
    char *word;
    int x1;
    int x2;
    int y1;
    int y2;
} NS_OCR_Item;

typedef struct
{
    int ocrItemCount;
    NS_OCR_Item *items;
} NS_OCR;

/**
 * Invoice recognition.
 */
int ns_invoice_recog(char *token, char *contentBuffer, long contentSize, NS_Invoice *result);
int ns_invoice_recog_file(char *token, char *filePath, NS_Invoice *result);

/**
 * Id card recognition.
 */
int ns_id_card_recog(char *token, char *contentBuffer, long contentSize, NS_Id_Card *result);
int ns_id_card_recog_file(char *token, char *filePath, NS_Id_Card *result);

/**
 * Vehicle plate license recognition.
 */
int ns_vehicle_plate_recog(char *token, char *contentBuffer, long contentSize, NS_Vehicle_Plate *result);
int ns_vehicle_plate_recog_file(char *token, char *filePath, NS_Vehicle_Plate *result);

/**
 * Band card recognition.
 */
int ns_bank_card_recog(char *token, char *contentBuffer, long contentSize, NS_Bank_Card *result);
int ns_bank_card_recog_file(char *token, char *filePath, NS_Bank_Card *result);

/**
 * OCR recognition.
 */
int ns_ocr_recog(char *token, char *contentBuffer, long contentSize, NS_OCR *result);
int ns_ocr_recog_file(char *token, char *filePath, NS_OCR *result);

#endif /* NINESKY_TEXT_RECOGNITION_NS_TEXT_RECOG_H_ */
